package com.bruan.d1_collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;

public class CollectionTest6 {
    public static void main(String[] args) {
        Collection<Movie> movies = new ArrayList<>();
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        movies.add(new Movie("xxxx",22.2,"dwdw"));
        System.out.println(movies);

        for (Movie movie : movies) {
            System.out.println(movie);
            System.out.println("name"+movie.getName());
            System.out.println("score"+movie.getScore());
            System.out.println("actor"+movie.getActor());
            System.out.println("-----------------------");
        }

        movies.forEach(new Consumer<Movie>() {
            @Override
            public void accept(Movie movie) {
                System.out.println(movie);
            }
        });
        movies.forEach(movie -> System.out.println(movie));
        //方法简略
        movies.forEach(System.out::println);
    }
}
